| Visual Basic (Declaration) | |
|---|---|
Public Overloads Function Read( _ ByVal buffer() As Byte, _ ByVal fill As Boolean _ ) As Integer | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As SegmentedStream Dim buffer() As Byte Dim fill As Boolean Dim value As Integer value = instance.Read(buffer, fill) | |
| C++/CLI | |
|---|---|
public: int Read( array<byte>^ buffer, bool fill ) | |
Parameters
- buffer
- The storage location for the received data.
- fill
- Always true, use this version of Read to completely fill the buffer
Return Value
The total number of bytes read into the buffer. This will either be the value of the count parameter, or zero if the stream has closed.| Exception | Description |
|---|---|
| System.IO.IOException | Thrown when the stream is not Readable. |
| System.ArgumentNullException | Thrown when the receiving buffer is null. |
| System.IO.EndOfStreamException | Thrown when the end of the stream was found before the required byte count was received. When this occurs the Available property will indicate how much data may be read and the CanRead Property will return true. |
This method reads data from the stream and returns when the provided buffer is completely full or end of stream is reached. This method is a good way to read fixed-length data. An example of this is with HTTP chunking, which occurs when the server breaks up the HTTP response into fixed-size chunks. Each chunk is preceded with a hexidecimal value notifying the receiver of the size of the data chunk to follow. Initialize a byte array to this value, then call this method to fill the byte array.
Target Platforms: Microsoft .NET Framework 2.0